*********************************************************************
* Long-term Change in Conflict Attitudes: A Dynamic Perspective     *
* Alon Yakter and Liran Harsgor 									*
* British Journal of Political Science (2022)						*
*                                                                   *
* Replication code - Supplementary material        					* *********************************************************************
* The analysis was performed with Stata 17. For model presentation, *
* users should install the estout package							* 
* (command line: "ssc install estout, replace").					*
*																	*
* to load the data (the "use" command), users should place the .dta	*
* file in their Stata working directory (or type the full file 		*
* paths as saved on their computer).                      			*
*********************************************************************
* open data
use "Yakter & Harsgor BJPS - data.dta", replace

** set data as time series
tsset ts_date, monthly

*********************************************************************
* SM section 2: Missing Observations and Interpolation - tables		*
*********************************************************************
* open data with alternative measures
* table A1
eststo clear
qui eststo: logit missing ///
	log_rockets ///
	if year_month>=200107 & year_month<=202005
qui eststo: logit missing ///
	 log_casualties ///
	if year_month>=200107 & year_month<=202005
qui eststo: logit missing ///
	 negotiations  ///
	if year_month>=200107 & year_month<=202005
qui eststo: logit missing ///
	 hawkish_selection ///
	if year_month>=200107 & year_month<=202005
qui eststo: logit missing ///
	log_rockets log_casualties negotiations hawkish_selection ///
	if year_month>=200107 & year_month<=202005
esttab,  ///
	b(3) se(3) pr2(3) aic(3) bic(3) ///	
	coeflabels(log_rockets LogRockets log_casualties LogCasualties ///
		negotiations Negotiations hawkish_selection HawkishLeadership ///
		_cons Constant) ///
	nomtitles nogaps compress

* Table A2
eststo clear
qui eststo: reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.support_ma_l100 l.support_ma_l100 ld.support_ma_l100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.support_ma_ex100 l.support_ma_ex100 ld.support_ma_ex100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.support_kal_st100 l.support_kal_st100 ld.support_kal_st100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.support_kal_ar100 l.support_kal_ar100 ld.support_kal_ar100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
esttab, ///
	b(3) se(3) r2(3) aic(3) bic(3) ///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	order(L.support_int_jw100 LD.support_int_jw100  ///
		L.support_ma_l100 LD.support_ma_l100 L.support_ma_ex100 LD.support_ma_ex100  ///
		L.support_kal_st100 LD.support_kal_st100 L.support_kal_ar100 LD.support_kal_ar100 ///
		D.log_rockets L.log_rockets D.log_casualties L.log_casualties D2.negotiations L.negotiations L2.negotiations ///
		D2.hawkish_selection L.hawkish_selection L2.hawkish_selection D.right_cab100 L.avewage D.avewage ts_date _cons) ///
	coeflabels(L.support_int_jw100 NetSupport.L LD.support_int_jw100 D.NetSupport.L ///
		L.log_rockets LogRockets.L D.log_rockets D.LogRockets ///
		L.log_casualties LogCasualties.L D.log_casualties D.LogCasualties ///
		L.negotiations Negotiations.L L2.negotiations Negotiations.L2 D2.negotiations D2.Negotiations ///
		L.hawkish_selection HawkishLeadership.L L2.hawkish_selection HawkishLeadership.L2 D2.hawkish_selection D2.HawkishLeadership ///
		D.right_cab100 D.RightCabinet L.avewage AverageWage.L D.avewage D.AverageWage ts_date Trend ///
		_cons Constant) ///
	mgroups("Linear" "MA Linear" "MA Exponential" "Kalman ML"  "Kalman ARIMA" , pattern(1 1 1 1 1)) ///
	nogaps  compress nomtitles
	
* table A3
eststo clear
qui eststo: reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.hope_ma_l100 l.hope_ma_l100 ld.hope_ma_l100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.hope_ma_ex100 l.hope_ma_ex100 ld.hope_ma_ex100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.hope_kal_st100 l.hope_kal_st100 ld.hope_kal_st100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.hope_kal_ar100 l.hope_kal_ar100 ld.hope_kal_ar100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
esttab, ///
	b(3) se(3) r2(3) aic(3) bic(3) ///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	order(L.hope_int_jw100 LD.hope_int_jw100  ///
		L.hope_ma_l100 LD.hope_ma_l100 L.hope_ma_ex100 LD.hope_ma_ex100  ///
		L.hope_kal_st100 LD.hope_kal_st100 L.hope_kal_ar100 LD.hope_kal_ar100 ///
		D.log_rockets L.log_rockets D.log_casualties L.log_casualties D2.negotiations L.negotiations L2.negotiations ///
		D2.hawkish_selection L.hawkish_selection L2.hawkish_selection D.right_cab100 L.avewage D.avewage ts_date _cons) ///
	coeflabels(L.hope_int_jw100 NetSupport.L LD.hope_int_jw100 D.NetSupport.L ///
		L.log_rockets LogRockets.L D.log_rockets D.LogRockets ///
		L.log_casualties LogCasualties.L D.log_casualties D.LogCasualties ///
		L.negotiations Negotiations.L L2.negotiations Negotiations.L2 D2.negotiations D2.Negotiations ///
		L.hawkish_selection HawkishLeadership.L L2.hawkish_selection HawkishLeadership.L2 D2.hawkish_selection D2.HawkishLeadership ///
		D.right_cab100 D.RightCabinet L.avewage AverageWage.L D.avewage D.AverageWage ts_date Trend ///
		_cons Constant) ///
	mgroups("Linear" "MA Linear" "MA Exponential" "Kalman ML"  "Kalman ARIMA" , pattern(1 1 1 1 1)) ///
	nogaps  compress nomtitles 
	
* table A4
eststo clear
qui eststo: reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date ///
	if year_month<=201910
qui eststo: reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date ///
	if year_month<=201910
esttab, ///
	b(3) se(3) r2(3) aic(3) bic(3) ///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	order(L.support_int_jw100 LD.support_int_jw100 L.hope_int_jw100 LD.hope_int_jw100 ///
		D.log_rockets L.log_rockets D.log_casualties L.log_casualties D2.negotiations L.negotiations L2.negotiations ///
		D2.hawkish_selection L.hawkish_selection L2.hawkish_selection D.right_cab100 L.avewage D.avewage ts_date _cons) ///
	coeflabels(L.support_int_jw100 NetSupport.L LD.support_int_jw100 D.NetSupport.L ///
		L.hope_int_jw100 NetHope.L LD.hope_int_jw100 D.NetHope.L ///
		L.log_rockets LogRockets.L D.log_rockets D.LogRockets ///
		L.log_casualties LogCasualties.L D.log_casualties D.LogCasualties ///
		L.negotiations Negotiations.L L2.negotiations Negotiations.L2 D2.negotiations D2.Negotiations ///
		L.hawkish_selection HawkishLeadership.L L2.hawkish_selection HawkishLeadership.L2 D2.hawkish_selection D2.HawkishLeadership ///
		D.right_cab100 D.RightCabinet L.avewage AverageWage.L D.avewage D.AverageWage ts_date Trend ///
		_cons Constant) ///
	mgroups("Net Support for Negotiations" "Net Hope for Peace in Practice", pattern(1 0 1 0)) ///
	nogaps compress nomtitles
	
*********************************************************************
* SM section 3: Independence of Violent and Non-Violent Events		*
*********************************************************************
** to pick the right DV lag length, a series of regressions followd by autocorrelation tests
* rockets 
foreach n of numlist 1/10 {
	dis "number of lags - " `n' ":"
	qui reg d.log_rockets ///
		negotiations hawkish_selection ///
		l(1/`n').log_rockets ts_date 
estat bgodfrey
}
* casualties
foreach n of numlist 1/10 {
	dis "number of lags - " `n' ":"
	qui reg d.log_casualties ///
		negotiations hawkish_selection ///
		l(1/`n').log_casualties ts_date 
estat bgodfrey
}

** Table A5
* (using the lag number that eliminiates autocorrelation in previous tests)
eststo clear
qui eststo: reg d.log_rockets ///
	negotiations ///
	l(1/6).log_rockets ts_date 
qui eststo: reg d.log_rockets ///
	hawkish_selection ///
	l(1/6).log_rockets ts_date 
qui eststo: reg d.log_rockets ///
	negotiations hawkish_selection ///
	l(1/6).log_rockets ts_date 
qui eststo: reg d.log_casualties ///
	negotiations ///
	l(1/5).log_casualties ts_date 
qui eststo: reg d.log_casualties ///
	hawkish_selection ///
	l(1/5).log_casualties ts_date 
qui eststo: reg d.log_casualties ///
	negotiations hawkish_selection ///
	l(1/5).log_casualties ts_date 
esttab, b(3) se(3) r2(3) aic(3) bic(3) ///
	keep(negotiations hawkish_selection) ///
	compress nogaps 

*********************************************************************
* SM section 4: Unit Root Tests	(for Table A6)						*
*********************************************************************
* determining what is the short and long lag truncation for tests (based on Schwert, by the advice of Webb et al 2020's online appendix)
foreach v of varlist support_int_jw hope_int_jw log_rockets log_casualties negotiations right_cab hawkish_selection avewage  {
	sum `v' if year_month>=200107 & year_month<=202005
	dis "Short lag truncation: " trunc(4 * (r(N)/100)^0.25)
	dis "Long lag truncation: " trunc(12 * (r(N)/100)^0.25)
	}

* tests for unit root: all variables
foreach v of varlist hawkish_selection {
	dis "`v':"
	dfuller `v' if year_month>=200107 & year_month<=202005, lags(1)
	dfuller `v' if year_month>=200107 & year_month<=202005, lags(1) trend
	pperron `v' if year_month>=200107 & year_month<=202005, lags(1)
	pperron `v' if year_month>=200107 & year_month<=202005, lags(1) trend
	dfgls `v' if year_month>=200107 & year_month<=202005, notrend
	dfgls `v' if year_month>=200107 & year_month<=202005
	lomackinlay `v' if year_month>=200107 & year_month<=202005, q(1 2 4 8 12 14)
	kpss `v' if year_month>=200107 & year_month<=202005, notrend
	kpss `v' if year_month>=200107 & year_month<=202005
	}

* dfgls tests by variable-specific suggested lags based on first test (Ng-Perron) and varsoc (AIC, BIC)
foreach v of varlist support_int_jw hope_int_jw log_rockets log_casualties negotiations right_cab hawkish_selection avewage {
	varsoc `v' if year_month>=200107 & year_month<=202005, maxlag(20)
	}
dfgls support_int_jw if year_month>=200107 & year_month<=202005, maxlag(3) notrend
dfgls support_int_jw if year_month>=200107 & year_month<=202005, maxlag(3)
dfgls support_int_jw if year_month>=200107 & year_month<=202005, maxlag(2) notrend
dfgls support_int_jw if year_month>=200107 & year_month<=202005, maxlag(2)
dfgls hope_int_jw if year_month>=200107 & year_month<=202005, maxlag(4) notrend
dfgls hope_int_jw if year_month>=200107 & year_month<=202005, maxlag(4)
dfgls log_rockets if year_month>=200107 & year_month<=202005, maxlag(3) notrend
dfgls log_rockets if year_month>=200107 & year_month<=202005, maxlag(3)
dfgls log_rockets if year_month>=200107 & year_month<=202005, maxlag(1) notrend
dfgls log_rockets if year_month>=200107 & year_month<=202005, maxlag(1)
dfgls log_casualties if year_month>=200107 & year_month<=202005, maxlag(5) notrend
dfgls log_casualties if year_month>=200107 & year_month<=202005, maxlag(5)
dfgls negotiations if year_month>=200107 & year_month<=202005, maxlag(0) notrend
dfgls negotiations if year_month>=200107 & year_month<=202005, maxlag(0)
dfgls right_cab if year_month>=200107 & year_month<=202005, maxlag(1) notrend
dfgls right_cab if year_month>=200107 & year_month<=202005, maxlag(1)
dfgls hawkish_selection if year_month>=200107 & year_month<=202005, maxlag(18) notrend
dfgls hawkish_selection if year_month>=200107 & year_month<=202005, maxlag(18)
dfgls hawkish_selection if year_month>=200107 & year_month<=202005, maxlag(0) notrend
dfgls hawkish_selection if year_month>=200107 & year_month<=202005, maxlag(0)
dfgls avewage if year_month>=200107 & year_month<=202005, maxlag(14) notrend
dfgls avewage if year_month>=200107 & year_month<=202005, maxlag(14)

* tests for unit root: first difference of variables with unit root
foreach v of varlist d.right_cab  {
	dis "`v':"
	dfuller `v' if year_month>=200107 & year_month<=202005, lags(1)
	dfuller `v' if year_month>=200107 & year_month<=202005, lags(1) trend
	pperron `v' if year_month>=200107 & year_month<=202005, lags(1)
	pperron `v' if year_month>=200107 & year_month<=202005, lags(1) trend
	dfgls `v' if year_month>=200107 & year_month<=202005, notrend
	dfgls `v' if year_month>=200107 & year_month<=202005
	lomackinlay `v' if year_month>=200107 & year_month<=202005, q(1 2 4 8 12 14)
	kpss `v' if year_month>=200107 & year_month<=202005, notrend
	kpss `v' if year_month>=200107 & year_month<=202005
	}

*********************************************************************
* SM section 5: Lag Selection (for plots see separate R codes)		*
*********************************************************************
** net support
* 1. collective lag selection
eststo clear
qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 log_rockets log_casualties negotiations hawkish_selection d.right_cab ///
	avewage ts_date
qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
	l(0/1).avewage ts_date
qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/2).log_rockets l(0/2).log_casualties l(0/2).negotiations l(0/2).hawkish_selection l(0/1).d.right_cab ///
	l(0/2).avewage ts_date
qui eststo: reg support_int_jw100 l(1/3).support_int_jw100 l(0/3).log_rockets l(0/3).log_casualties l(0/3).negotiations l(0/3).hawkish_selection l(0/2).d.right_cab ///
	l(0/3).avewage ts_date
qui eststo: reg support_int_jw100 l(1/4).support_int_jw100 l(0/4).log_rockets l(0/4).log_casualties l(0/4).negotiations l(0/4).hawkish_selection l(0/3).d.right_cab ///
	l(0/4).avewage ts_date
qui eststo: reg support_int_jw100 l(1/5).support_int_jw100 l(0/5).log_rockets l(0/5).log_casualties l(0/5).negotiations l(0/5).hawkish_selection l(0/4).d.right_cab ///
	l(0/5).avewage ts_date
qui eststo: reg support_int_jw100 l(1/6).support_int_jw100 l(0/6).log_rockets l(0/6).log_casualties l(0/6).negotiations l(0/6).hawkish_selection l(0/5).d.right_cab ///
	l(0/6).avewage ts_date
qui eststo: reg support_int_jw100 l(1/7).support_int_jw100 l(0/7).log_rockets l(0/7).log_casualties l(0/7).negotiations l(0/7).hawkish_selection l(0/6).d.right_cab ///
	l(0/7).avewage ts_date
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
* 2. individual lag selection, while rest held in 1L (1L = best model collectively by previous step)
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/`n').log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date	
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/`n').log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
		}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/`n').negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/`n').hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 0/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection l(0/`n').d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/`n').avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
	* 2A. examine whether both second lags for negotiatoins and extremists work together or alone
	eststo clear
	foreach n of numlist 1/6 {
		qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations l(0/`n').hawkish_selection d.right_cab ///
			l(0/1).avewage ts_date
		}
	esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
	eststo clear
	foreach n of numlist 1/6 {
		qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/`n').negotiations l(0/2).hawkish_selection d.right_cab ///
			l(0/1).avewage ts_date
		}
	esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
* 3. second iteration - all other variables after adding second lag to negotiations aned extremists (based on first iteration)
eststo clear
foreach n of numlist 2/6 {
	qui eststo: reg support_int_jw100 l(1/`n').support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/`n').log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab  ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/`n').log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab  ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 0/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection l(0/`n').d.right_cab  ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg support_int_jw100 l(1/2).support_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab  ///
		l(0/`n').avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress

** net hope
* 1. collective lag selection
eststo clear
qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
	l(0/1).avewage ts_date
qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/2).log_rockets l(0/2).log_casualties l(0/2).negotiations l(0/2).hawkish_selection l(0/1).d.right_cab ///
	l(0/2).avewage ts_date
qui eststo: reg hope_int_jw100 l(1/3).hope_int_jw100 l(0/3).log_rockets l(0/3).log_casualties l(0/3).negotiations l(0/3).hawkish_selection l(0/2).d.right_cab ///
	l(0/3).avewage ts_date
qui eststo: reg hope_int_jw100 l(1/4).hope_int_jw100 l(0/4).log_rockets l(0/4).log_casualties l(0/4).negotiations l(0/4).hawkish_selection l(0/3).d.right_cab ///
	l(0/4).avewage ts_date
qui eststo: reg hope_int_jw100 l(1/5).hope_int_jw100 l(0/5).log_rockets l(0/5).log_casualties l(0/5).negotiations l(0/5).hawkish_selection l(0/4).d.right_cab ///
	l(0/5).avewage ts_date
qui eststo: reg hope_int_jw100 l(1/6).hope_int_jw100 l(0/6).log_rockets l(0/6).log_casualties l(0/6).negotiations l(0/6).hawkish_selection l(0/5).d.right_cab ///
	l(0/6).avewage ts_date
qui eststo: reg hope_int_jw100 l(1/7).hope_int_jw100 l(0/7).log_rockets l(0/7).log_casualties l(0/7).negotiations l(0/7).hawkish_selection l(0/6).d.right_cab ///
	l(0/7).avewage ts_date
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
* 2. individual lag selection, while rest held in 1L (1L = best model collectively by previous step)
eststo clear
foreach n of numlist 2/6 {
	qui eststo: reg hope_int_jw100 l(1/`n').hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/`n').log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date	
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/`n').log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
		}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/`n').negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/`n').hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 0/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection l(0/`n').d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/1).negotiations l(0/1).hawkish_selection d.right_cab ///
		l(0/`n').avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
	* 2A. examine whether both second lags for negotiatoins and extremists work together or alone
	eststo clear
	foreach n of numlist 1/6 {
		qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations l(0/`n').hawkish_selection d.right_cab ///
			l(0/1).avewage ts_date
		}
	esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
	eststo clear
	foreach n of numlist 1/6 {
		qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/`n').negotiations l(0/2).hawkish_selection d.right_cab ///
			l(0/1).avewage ts_date
		}
	esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
* 3. second iteration - all other variables after adding second lag to negotiations aned extremists (based on first iteration)
eststo clear
foreach n of numlist 2/6 {
	qui eststo: reg hope_int_jw100 l(1/`n').hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/`n').log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab  ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/`n').log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab  ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 0/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection l(0/`n').d.right_cab  ///
		l(0/1).avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress
eststo clear
foreach n of numlist 1/6 {
	qui eststo: reg hope_int_jw100 l(1/2).hope_int_jw100 l(0/1).log_rockets l(0/1).log_casualties l(0/2).negotiations  l(0/2).hawkish_selection d.right_cab  ///
		l(0/`n').avewage ts_date
	}
esttab, p(3) r2(3) aic(3) bic(3) nogaps compress


*********************************************************************
* SM section 6: Autocorrelation Tests								*
*********************************************************************
** autocorrelation tests for Table A7
* net support
	* single DV lag (standard ECM)
	qui reg d.support_int_jw100 l.support_int_jw100 ///
		l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
		d.right_cab100 l.avewage d.avewage ts_date
	estat bgodfrey
	predict q1, res
	wntestq q1
	drop q1
	* additional DV lag / Delta LDV
	qui reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
		l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
		d.right_cab100 l.avewage d.avewage ts_date
	estat bgodfrey
	predict q1, res
	wntestq q1
	drop q1
* net hope
	* single DV lag (standard ECM)
	qui reg d.hope_int_jw100 l.hope_int_jw100 ///
		l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
		d.right_cab100 l.avewage d.avewage ts_date
	estat bgodfrey
	predict q1, res
	wntestq q1
	drop q1
	* additional DV lag / Delta LDV
	qui reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
		l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
		d.right_cab100 l.avewage d.avewage ts_date
	estat bgodfrey
	predict q1, res
	wntestq q1
	drop q1

** seasonality tests for table A8
* net support
qui reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
predict q1, res
wntestq q1, lags(6)
wntestq q1, lags(12)
wntestq q1, lags(24)
drop q1
* net hope
qui reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
predict q1, res
wntestq q1, lags(6)
wntestq q1, lags(12)
wntestq q1, lags(24)
drop q1

*********************************************************************
* SM section 7: Structural Breakpoint Characteristics								*
*********************************************************************
* table A9
eststo clear
qui eststo: reg support_int_jw100  ///
	c.ts_date i.jan06 tXjan06 i.apr09 tXapr09 i.oct16 tXoct16
qui eststo: reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	c.ts_date i.jan06 tXjan06 i.apr09 tXapr09 i.oct16 tXoct16
esttab, ///
	b(3) se(3) r2(3) aic(3) bic(3) ///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	order(ts_date 1.jan06 tXjan06 1.apr09 tXapr09 1.oct16 tXoct16 ///
		L.support_int_jw100 LD.support_int_jw100) ///
	drop(_cons 	0*) ///
	coeflabels(L.support_int_jw100 NetSupport.L LD.support_int_jw100 D.NetSupport.L ///
		ts_date Trend ///
		_cons Constant) ///
	nogaps compress nomtitles

* table A10
eststo clear
qui eststo: reg hope_int_jw100 ///
	c.ts_date i.apr06 tXapr06 i.sep13 tXsep13
qui eststo: reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	c.ts_date i.apr06 tXapr06 i.sep13 tXsep13
esttab, ///
	b(3) se(3) r2(3) aic(3) bic(3) ///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	order(ts_date 1.apr06 tXapr06 1.sep13 tXsep13 ///
		L.hope_int_jw100 LD.hope_int_jw100) ///
	drop(_cons 	0*) ///
	coeflabels(L.hope_int_jw100 NetHope.L LD.hope_int_jw100 D.NetHope.L ///
		ts_date Trend ///
		_cons Constant) ///
	nogaps compress nomtitles 
